package com.littleu.yojoincn.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.littleu.yojoincn.common.exception.http.NotFoundException;
import com.littleu.yojoincn.dto.customer.CustomerDTO;
import com.littleu.yojoincn.mapper.CustomerMapper;
import com.littleu.yojoincn.model.CustomerDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class CustomerService extends ServiceImpl<CustomerMapper, CustomerDO> {
    public Long update(CustomerDTO dto, Long id){
        CustomerDO customerDO = this.getById(id);
        if(customerDO == null) {
            throw new NotFoundException(10002);
        }
        Long cid = customerDO.getCelebrityId();
        BeanUtils.copyProperties(dto, customerDO);
        this.updateById(customerDO);
        return cid;
    }
}
